package com.zkingsoft.actions.admin;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.httpclient.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.zkingsoft.constance.Dictionary;
import com.zkingsoft.dao.WorkLogDao;
import com.zkingsoft.plugin.util.DateUtils;
import com.zkingsoft.plugin.util.LogUtil;
import com.zkingsoft.services.WorkLogService;
import com.zkingsoft.thread.SendWorkLogThread;


@Component
public class workLogScheduler{
	@Autowired
	private WorkLogDao workLogDao;
	
	
	
//	@Scheduled(cron = "0 0/1 * * * ?")
	@Scheduled(cron = "${log.time}")
	public void run() {
		List<Map<String,Object>> mapList=workLogDao.selectUsersId();
		for(Map map:mapList){
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			String[] dates = {df.format(DateUtils.nextDate((Date) map.get("endTime"))),df.format(DateUtils.nextNDate((Date) map.get("endTime"),2)),df.format(DateUtils.nextNDate((Date) map.get("endTime"),3))};
			SendWorkLogThread sendWork = new SendWorkLogThread(workLogDao,map,Dictionary.BG_COLOR_FINISHED,Dictionary.DINGDING_PUSH_TITLE,dates);
			new Thread(sendWork).start();
		}
		LogUtil.info("查询是否有未写日志的情况#{}",mapList);
		
		
	}
}
